package uscdb.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

@Entity
@Table(name = "tusertreview")
@DynamicInsert(true)
@DynamicUpdate(true)
public class Tusertreview implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3978138505322964828L;

	private String id;

	// 对应的user
	private Tuser tuser = new Tuser();

	// 对应的review
	private Treview treview = new Treview();

	// user与review关联的导入次数
	private Integer times = 0;

	@Id
	@Column(name = "ID", nullable = false, length = 36)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@Cascade(value = CascadeType.SAVE_UPDATE)
	@JoinColumn(name = "TUSER_ID")
	public Tuser getTuser() {
		return tuser;
	}

	public void setTuser(Tuser tuser) {
		this.tuser = tuser;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@Cascade(value = CascadeType.SAVE_UPDATE)
	@JoinColumn(name = "TREVIEW_ID")
	public Treview getTreview() {
		return treview;
	}

	public void setTreview(Treview treview) {
		this.treview = treview;
	}

	@Column(name = "times")
	public Integer getTimes() {
		return times;
	}

	public void setTimes(Integer times) {
		this.times = times;
	}

	public Tusertreview() {
		super();
	}

	public Tusertreview(String id, Tuser tuser, Treview treview, Integer times) {
		super();
		this.id = id;
		this.tuser = tuser;
		this.treview = treview;
		this.times = times;
	}

}
